﻿using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Blog.System.HttpApi.Hosting.Filters
{
    public class BlogExceptionFilter : IExceptionFilter
    {
        private readonly ILogger<BlogExceptionFilter> _log;
        public BlogExceptionFilter(ILogger<BlogExceptionFilter> log) 
        {
            _log = log;
        }

        public void OnException(ExceptionContext context) 
        {
            _log.LogError($"{context.HttpContext.Request.Path}|{context.Exception.Message}", context.Exception);
        }
    }
}
